<?php

namespace App\Http\Controllers\Member;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Member\Address;
use Auth;

class AddressController extends Controller
{
    // 地址列表
    public function getAddressLists()
    {
        $user = Auth::user()->toArray();
        $Address = new Address;
        $addressLists = $Address->getAddressLists($user['id'], $user['address_id']);
        return $addressLists;
    }

    // 新增 / 编辑地址
    public function insertAddress(Request $request)
    {
        $user = Auth::user()->toArray();
        $request['user_id'] = $user['id'];
        $request['address_id'] = $user['address_id'];
        $Address = new Address;
        $addressChange = $Address->addressChange($request);   
        return $addressChange;
    }

    // 删除地址
    public function delAddress(Request $request)
    {
        $user = Auth::user()->toArray();
        $Address = new Address;
        $addressDel = $Address->delAddress($request['id'], $user);
        return $addressDel;
    }
}
